<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2023/4/25
  Time: 15:20
  To change this template use File | Settings | File Templates.
--%>
<%--
  Created by IntelliJ IDEA.
  User: 87070
  Date: 2022/10/24
  Time: 18:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <title>登录页</title>

    <link href="${pageContext.request.contextPath}/static/css/frontlogin.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-3.6.1.min.js"></script>


</head>
<body>
<!-- 这里创建一个表单 将它的样式类名设置为login-form -->
<form action="" class="login-form" id="loginForm">
    <h1>登录</h1>
    <!-- 这里创建用户名框 -->
    <div class="txtb">
        姓名：<input type="text" name="username" value="ppp1">
        <!-- 这里给span标签自定义一个占位符，为了之后的小效果 -->
<%--        <span data-placeholder="姓名"></span>--%>
    </div>
    <!-- 电话号码 -->
    <div class="txtb">
        电话号码：<input type="text" name="tel" id="tel" value="54789031245">
<%--        <span data-placeholder="电话号码" ></span>--%>
    </div>
    <div class="txtb">
        邀请码：<input type="text" name="yqcode" id="yqcode" value="f7719">
<%--        <span data-placeholder="邀请码"></span>--%>
    </div>
    <!-- 搭建登录按钮和注册连接 -->
    <input type="button" class="logbtn" onclick="userLogin()" value="登录">

</form>

<script>
    function userLogin(){
        $.ajax({
            url:"${pageContext.request.contextPath}/frontLogin",
            data:$("#loginForm").serialize(),
            type:"post",
            success:function (res){
                console.log(res)
                if(res.msg!=="操作成功"){
                    alert(res.msg)
                }else {
                    window.location="${pageContext.request.contextPath}/indexServlet";
                }
            }
        })
    }
    $(function(){
        // 利用jquery监听 焦点 和 失焦两个事件来动态设置样式控制效果
        $(".txtb input").on("focus",function(){
            $(this).addClass("focus")
        })
        $(".txtb input").on("blur",function(){
            if($(this).val() == "")
                $(this).removeClass("focus")
        })
    })



    //某个时间段室内是否含有这个时间如果含有就返回true 否则就false
    function  isDuringDate(beginDateStr, endDateStr) {
        // alert(beginDateStr+"=="+endDateStr);
        var curDate = new Date(),
            beginDate = new Date(Date.parse(beginDateStr.replace(/-/g,   "/"))),
            endDate = new Date(Date.parse(endDateStr.replace(/-/g,   "/")));


        // alert(curDate+"=="+beginDate+"---"+endDate);
        return curDate >= beginDate && curDate < endDate;

    }
</script>



</body>
</html>


